using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ReinsPlugin
{
    [Serializable]
    public class ReinsData
    {
        private ReinsPlugin.SearchData searchData;

        public ReinsData()
        {
            searchData = new SearchData();
        }
    
        public SearchData SearchData
        {
            get
            {
                return searchData;
            }
            set
            {
                searchData = value;
            }
        }

        public static ReinsData Load()
        {
            ReinsData reinsData = new ReinsData();
            try
            {
                using (System.IO.StreamReader reader = new System.IO.StreamReader("ReinsData.xml"))
                {
                    System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(ReinsData));
                    reinsData = (ReinsData)xs.Deserialize(reader);
                    reader.Close();
                }
            }
            catch (System.IO.FileNotFoundException e)
            {
                e.ToString();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
            return reinsData;
        }

        public static void Store(ReinsData reinsData)
        {
            try
            {
                using (System.IO.StreamWriter writer = new System.IO.StreamWriter("ReinsData.xml"))
                {
                    System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(ReinsData));
                    xs.Serialize(writer, reinsData);
                    writer.Close();
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
    }
}
